# print(1 + 2 - 3)
# print(1 + 2 * 3)
# print(1 + 2 / 3)

# print( (67.5 + 89.0 + 12.9 + 32.2) / 4 )

# avg = (67.5 + 89.0 + 12.9 + 32.2) / 4
# total = (67.5 - avg) ** 2 + (89.0 - avg) ** 2 + (12.9 - avg) ** 2 + (32.2 - avg)** 2
# result = total / 3
# print(result)



# a = 10
# print(type(a))
#
# a = 0.5
# print(type(a))
#
# a = 'hello'
# print(type(a))
#
# a = 'hello'
# print(len(a))
#
# a = 'hello'
# b = 'world'
# print(a + b)
#
# a = True
# print(type(a))
# b = False
# print(type(b))

# a = 10
# print(type(a))
# a = 'hello'
# print(type(a))

# num = 0
# num = input('请输入一个整数: ')
# print(f'你输入的整数是 {num}')



# a = input('请输入第一个整数: ')
# b = input('请输入第二个整数: ')
# print(f'a + b = {a + b}')

# a = input('请输入第一个整数: ')
# b = input('请输入第二个整数: ')
# a = int(a)
# b = int(b)
# print(f'a + b = {a + b}')

# a = input('请输入第一个数字: ')
# b = input('请输入第二个数字: ')
# c = input('请输入第三个数字: ')
# d = input('请输入第四个数字: ')
# a = float(a)
# b = float(b)
# c = float(c)
# d = float(d)
# avg = (a + b + c + d) / 4
# print(f'平均值: {avg}')

# print(10 / 0)
# print(1 / 2)
# print(7 % 2)

# print(4 ** 2)
# print(4 ** 0.5)

# print(7 // 2)
# print(-7 // 2)

# a = 10
# b = 20
# print(a < b)
# print(a <= b)
# print(a > b)
# print(a >= b)
# print(a == b)
# print(a != b)

# a = 'hello'
# b = 'world'
# print(a < b)
# print(a <= b)
# print(a > b)
# print(a >= b)
# print(a == b)
# print(a != b)

# print(0.1 + 0.2 == 0.3)

# print(0.1)
# print(0.2)
# print(0.3)
# print(0.1 + 0.2)


# a = 10
# b = 20
# c = 30
# print(a < b and b < c)
# print(a < b and b > c)
# print(a > b or b > c)
# print(a < b or b > c)
# print(not a < b)
# print(not a > b)

# print(10 > 20 and 10 / 0 == 1)
# print(10 < 20 or 10 / 0 == 1)

# import random  # 导入随机模块（生成随机数）
#
# # 1. 打印游戏欢迎语
# print("=" * 20)
# print("花有重开日，人无再少年")
# print("欢迎来到：人生重开模拟器")
# print("=" * 20)
#
# # 2. 循环输入初始属性（总点数≤20，每个属性1-10）
# while True:
#     print("\n请设定初始属性（可用总点数20，每个属性1-10）")
#     face = int(input("颜值："))
#     strong = int(input("体质："))
#     iq = int(input("智力："))
#     home = int(input("家境："))
#
#     # 条件判断：属性是否合法
#     if face < 1 or face > 10:
#         print("颜值必须在1-10之间！")
#         continue  # 跳过本次循环，重新输入
#     if strong < 1 or strong > 10:
#         print("体质必须在1-10之间！")
#         continue
#     if iq < 1 or iq > 10:
#         print("智力必须在1-10之间！")
#         continue
#     if home < 1 or home > 10:
#         print("家境必须在1-10之间！")
#         continue
#     if face + strong + iq + home > 20:
#         print("总点数超过20了！")
#         continue
#
#     # 所有条件合法，退出循环
#     print("初始属性设定完成！")
#     break
#
# # 3. 随机性别（1-6的随机数，单数=男孩，双数=女孩）
# gender_point = random.randint(1, 6)
# if gender_point % 2 == 1:
#     gender = "男孩"
# else:
#     gender = "女孩"
# print(f"\n你是个{gender}")
#
# # 4. 按家境随机出生点（多分支条件）
# birth_point = random.randint(1, 3)  # 1-3的随机数，细分出生情况
# print("\n你的出生情况：")
# if home == 10:
#     print("你出生在帝都，父母是高官政要")
#     home += 1
#     iq += 1
#     face += 1
# elif 7 <= home <= 9:
#     if birth_point == 1:
#         print("你出生在大城市，父母是公务员")
#         face += 2
#     elif birth_point == 2:
#         print("你出生在大城市，父母是大企业高管")
#         home += 2
#     else:
#         print("你出生在大城市，父母是大学教授")
#         iq += 2
# else:
#     print("你出生在普通家庭，父母是工薪阶层")
#     strong += 1
#
# # 5. 打印最终初始属性
# print(f"\n最终初始属性：颜值{face}，体质{strong}，智力{iq}，家境{home}")
# print("人生之旅即将开始！")

# def calcSum(beg, end):
#     sum = 0
#     for i in range(beg, end+1):
#         sum += i
#     print(sum)
#
# calcSum(1, 100)
# calcSum(300, 400)
# calcSum(1, 10000)

# def test(a, b, c):
#     print(a, b, c)
#
# test(10)

# def test(a):
#  print(a)
#
#
# test(10)
# test('hello')
# test(True)

# def calcSum(beg, end):
#     sum = 0
#     for i in range(beg, end + 1):
#         sum += i
#     print(sum)
#
# calcSum(1, 100)


# def calcSum(beg, end):
#     sum = 0
#     for i in range(beg, end + 1):
#         sum += i
#     return sum
#
# result = calcSum(1, 100)
# print(result)


# # 判定是否是奇数
# def isOdd(num):
#  if num % 2 == 0:
#   return False
#  else:
#   return True
#
# result = isOdd(10)
# print(result)


# def getPoint():
#  x = 10
#  y = 20
#  return x, y
#
# a, b = getPoint()

# def getPoint():
#  x = 10
#  y = 20
#  return x, y
#
# _, b = getPoint()

# alist = [1, 2, 3, 4]
# print(alist[1:3])

# alist = [1, 2, 3, 4]
# print(alist[1:])        # 省略后边界, 表示获取到列表末尾
# print(alist[:-1])       # 省略前边界, 表示从列表开头获取
# print(alist[:])         # 省略两个边界, 表示获取到整个列表


# alist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# print(alist[::1])
# print(alist[::2])
# print(alist[::3])
# print(alist[::5])

# alist = [1, 2, 3, 4]
# print(alist[100:200])

# alist = [1, 2, 3, 4]
# for elem in alist:
#    print(elem)

# alist = [1, 2, 3, 4]
# print(2 in alist)
# print(10 in alist)

# alist = [1, 2, 3, 4]
# print(alist.index(2))
# print(alist.index(10))

# alist = [1, 2, 3, 4]
# alist.pop()
# print(alist)

# alist = [1, 2, 3, 4]
# alist.pop(2)
# print(alist)

# alist = [1, 2, 3, 4]
# alist.remove(2)
# print(alist)

# alist = [1, 2, 3, 4]
# blist = [5, 6, 7]
# print(alist + blist)

# alist = [1, 2, 3, 4]
# blist = [5, 6, 7]
# alist.extend(blist)


# print(alist)
# print(blist)

# def getPoint():
# 	return 10, 20
# result = getPoint()
# print(type(result))

# a = { }
# b = dict()
# print(type(a))
# print(type(b))
#
# student = { 'id': 1, 'name': 'zhangsan' }
# print(student)

# student = {
# 	 'id': 1,
# 	 'name': 'zhangsan',
#  }
# print('id' in student)
# print('score' in student)


# student = {
# 	 'id': 1,
# 	 'name': 'zhangsan',
#  }
# print(student['id'])
# print(student['name'])

# student = {
#  	'id': 1,
#  	'name': 'zhangsan',
#  }
# print(student['score'])

# student = {
#  'id': 1,
#  'name': 'zhangsan',
# }
# student['score'] = 90
# print(student)


# student = {
#  	'id': 1,
#  	'name': 'zhangsan',
#  	'score': 80
#  }
# student['score'] = 90
# print(student)

# student = {
#  	'id': 1,
#  	'name': 'zhangsan',
#  	'score': 80
#  }
# student.pop('score')
# print(student)

# student = {
#   'id': 1,
#   'name': 'zhangsan',
#  'score': 80
#  }
# for key in student:
#     print(key, student[key])

# student = {
#  	'id': 1,
#  	'name': 'zhangsan',
#  	'score': 80
# }
# print(student.keys())
# print(student.values())
# print(student.items())

# print(hash(0))
# print(hash(3.14))
# print(hash('hello'))
# print(hash(True))
# print(hash(()))           # ( ) 是一个空的元组

# print(hash([1, 2, 3]))

# print(hash({ 'id': 1 }))

# flist = []
# count = 0
# while True:
#   f = open('D:\Code\python\pythonProject1\code01.py', 'r')
#   flist.append(f)
#   count += 1
#   print(f'count = {count}')

# f = open('D:\Code\python\pythonProject1\code01.py', 'w')
# f.write('hello')
# f.close()

# f = open('d:/test.txt', 'w')
# f.write('hello')
# f.close()
# f = open('d:/test.txt', 'a')
# f.write('world')
# f.close()

# f = open('d:/test.txt', 'r')
# result = f.read(2)
# print(result)
# f.close()

# f = open('d:/test.txt', 'r')
# for line in f:
#     print(f'line = {line}')
# f.close()

# # 以只读模式打开文件
# f = open('d:/test.txt', 'r', encoding='utf-8')
# for line in f:
#     # 用 end='' 取消 print 自带的换行（因为每行本身已含换行符）
#     print(f"今日计划：{line}", end='')
# f.close()

# 以只读模式打开文件
f = open('d:/test.txt', 'r', encoding='utf-8')
lines = f.readlines()
print("所有计划（列表形式）：", lines)
f.close()